import { createRouter, createWebHistory } from 'vue-router';
import HomePage from '@/views/HomePage.vue';
import LoginPage from '@/views/Login.vue';
import RegisterPage from '@/views/Register.vue';
import TeamPage from '@/views/TeamPage.vue';
import AbilityMapPage from '@/views/AbilityMap.vue';
import CourseIntroductionPage from '@/views/CourseIntroduction.vue';
import KnowledgeMapPage from '@/views/KnowledgeMap.vue';
import QuestionMapPage from '@/views/QuestionMap.vue';
import ValueMapPage from '@/views/ValueMap.vue';
import QA from '@/views/QA.vue';
import QADetail from'@/views/QADetail.vue';//话题详情//公共

import NewAssignment from '@/views/NewAssignment.vue';//新增作业
import AdvancedSettings from '@/views/AdvancedSettings.vue'; // 导入新组件
import AssignmentDetail from '@/views/AssignmentDetail.vue';
import AssignmentList from '@/views/AssignmentList.vue';
import StudentAssignmentReview from '@/views/StudentAssignmentReview.vue';
import EditExamPage from '@/views/EditExamPage.vue';
import EditExamdetail from '@/views/EditExamdetail.vue';
import StuServayDetail from '@/views/StuServayDetail.vue';
import EditSurveydetail from '@/views/EditSurveydetail.vue';
import AnswerReview from '@/views/AnswerReview.vue';
import ExamDetail from '@/views/ExamDetail.vue';
import PaperPreview from '@/views/PaperPreview.vue';
import PaperEdit from '@/views/PaperEdit.vue';
import AnalysisReport from '@/views/AnalysisReport.vue';
import SurveyAnalysis from '@/views/SurveyAnalysis.vue';
import ExamSettings from '@/views/ExamSettings.vue';


import TeacherLayout from '@/layouts/TeacherLayout.vue';
import TeacherProfile from '@/pages/teacher/TeacherProfile.vue';
import T_ClassPage from '@/pages/teacher/T_ClassPage.vue';
import T_QA from '@/pages/teacher/T_QA.vue';
import TeacherSet from '@/pages/teacher/TeacherSet.vue';
import T_ImagesPage from '@/pages/teacher/T_ImagesPage.vue';
import T_WordPage from '@/pages/teacher/T_WordPage.vue';
import T_VideosPage from '@/pages/teacher/T_VideosPage.vue';
import T_OtherResourcesPage from '@/pages/teacher/T_OtherResourcesPage.vue';
import T_QuestionBankPage from '@/pages/teacher/T_QuestionBankPage.vue';
import T_ExamBankPage from '@/pages/teacher/T_ExamBankPage.vue'; // 教师

import T_ClassLayout from '@/layouts/T_ClassLayout.vue';
import T_ClassManagement from '@/pages/teacher/ClassManagement.vue'; // 教师管理
import TechNoti from '@/pages/teacher/TechNoti.vue'; 
import TechAssignments from '@/pages/teacher/TechAssignments.vue'; 
import TechExams from '@/pages/teacher/TechExams.vue'; 
import TechResources from '@/pages/teacher/TechResources.vue'; 
import TechVideos from '@/pages/teacher/TechVideos.vue'; 
import TechMaterials from '@/pages/teacher/TechMaterials.vue'; 
import TechOther from '@/pages/teacher/TechOther.vue'; 
import TechSurveys from '@/pages/teacher/TechSurveys.vue'; 
import TechData from '@/pages/teacher/TechData.vue'; 
import ResourceViewer from '@/pages/teacher/ResourceViewer.vue'; 


import S_ClassLayout from '@/layouts/S_ClassLayout.vue'; // 学生管理
import StuNoti from '@/pages/student/StuNoti.vue'; 
import StuAssignments from '@/pages/student/StuAssignments.vue'; 
import StuExams from '@/pages/student/StuExams.vue'; 
import StuResources from '@/pages/student/StuResources.vue'; 
import StuVideos from '@/pages/student/StuVideos.vue'; 
import StuMaterials from '@/pages/student/StuMaterials.vue'; 
import StuOther from '@/pages/student/StuOther.vue'; 
import StuSurveys from '@/pages/student/StuSurveys.vue'; 
import StuData from '@/pages/student/StuData.vue'; 
import StuQuestion from '@/pages/student/StuQuestion.vue'; 

import StuPaperPreview from '@/views/StuPaperPreview.vue';
import StuExamSettings from '@/views/StuExamSettings.vue';
import StuAnswerReview from '@/views/StuAnswerReview.vue';
import StuAssignmentList from '@/views/StuAssignmentList.vue';
import StuAdvancedSettings from '@/views/StuAdvancedSettings.vue';
import StuEach from '@/views/StuEach.vue';
import StudentLayout from '@/layouts/StudentLayout.vue';
import StudentProfile from '@/pages/student/StudentProfile.vue';
import ClassPage from '@/pages/student/ClassPage.vue';
import PPTPage from '@/pages/student/PPTPage.vue';
import VideosPage from '@/pages/student/VideosPage.vue';
import ImagesPage from '@/pages/student/ImagesPage.vue';
import QuestionBankPage from '@/pages/student/QuestionBankPage.vue';
import WordPage from '@/pages/student/WordPage.vue';
import StudentSet from '@/pages/student/StudentSet.vue'; 
import StuResourceViewer from '@/pages/student/StuResourceViewer.vue'; // 学生

const routes = [
  { path: '/', component: HomePage, meta: { title: '首页' } },
  { path: '/login', component: LoginPage, meta: { title: '登录' } },
  { path: '/register', component: RegisterPage, meta: { title: '注册' } },
  { path: '/team', component: TeamPage, meta: { title: '教学团队' } },
  { path: '/ability-map', component: AbilityMapPage, meta: { title: '能力图谱' } },
  { path: '/course-introduction', component: CourseIntroductionPage, meta: { title: '课程介绍' } },
  { path: '/knowledge-map', component: KnowledgeMapPage, meta: { title: '知识图谱' } },
  { path: '/question-map', component: QuestionMapPage, meta: { title: '问题图谱' } },
  { path: '/value-map', component: ValueMapPage, meta: { title: '价值图谱' } },
  { path: '/qa', name:'qa',component: QA, meta: { title: '互动问答' },},
  { path: '/qa-detail',name:'qa-detail',props:true, component: QADetail, meta: { title: '话题详情' } },
  //公共

  { path: '/teacher-profile', component: TeacherProfile, meta: { title: '教师个人中心' } },
  { path: '/student-profile', component: StudentProfile, meta: { title: '学生个人中心' } },
  { path: '/new-assignment/:semesterId', name: 'NewAssignment',component: NewAssignment,props: true, meta: { title: '新增作业' } },
  { path: '/advanced-settings/:homeworkId/:semesterId', name: 'AdvancedSettings', component: AdvancedSettings, props: true, meta: { breadcrumb: '高级设置' }},
  { path: '/assignment/:homeworkId/:semesterId', name: 'AssignmentDetail', component: AssignmentDetail, props: true,meta: { breadcrumb: '作业详细' }},
  { path: '/assignmen-list/:homeworkId/:semesterId', name: 'AssignmentList', component: AssignmentList, props: true,meta: { breadcrumb: '作业列表' } },
  { path: '/stuassignmen-list/:homeworkId/:semesterId', name: 'StuAssignmentList', component: StuAssignmentList, props: true,meta: { breadcrumb: '作答情况' } },
  { path: '/stuadvanced-settings/:homeworkId/:semesterId', name: 'StuAdvancedSettings', component: StuAdvancedSettings, props: true, meta: { breadcrumb: '作业规则' }},
  { path: '/stueach/:homeworkId/:semesterId', name: 'StuEach', component: StuEach, props: true, meta: { breadcrumb: '互评情况' }},
  { path: '/homework/:homeworkId/student/:stuHmwkId',name: 'StudentAssignmentReview',component: StudentAssignmentReview,props: true, },// 允许将路由参数作为 props 传递给组件
{
  path: '/exam/:semesterId/:examId/',
  props: true,
  children: [
    { 
      path: 'detail',
      name: 'ExamDetail',
      component: ExamDetail,
      meta: { breadcrumb: '答题列表' } ,
      props: route => ({ 
        semesterId: route.params.semesterId,
        examId: route.params.examId
      })
    },
    { 
      path: 'preview',
      name: 'PaperPreview',
      component: PaperPreview,
      meta: { breadcrumb: '试卷预览' } 
    },
    { 
      path: 'edit',
      name: 'PaperEdit',
      component: PaperEdit,
      meta: { breadcrumb: '试卷编辑' } 
    },
    { 
      path: 'analysis',
      name: 'AnalysisReport',
      component: AnalysisReport,
      meta: { breadcrumb: '统计分析' },
    },
    { 
      path: 'settings',
      name: 'ExamSettings',
      component: ExamSettings,
      meta: { breadcrumb: '规则设置' } 
    },
    { 
      path: 'answer-review',
      name: 'AnswerReview',
      component: AnswerReview,
      meta: { breadcrumb: '作答情况' } 
    }
    
  ]
},
{
  path: '/survey/:semesterId/:surveyId/',
  props: true,
  children: [
    { 
      path: 'sur-analysis',
      name: 'SurveyAnalysis',
      component: SurveyAnalysis,
      meta: { breadcrumb: '问卷分析' },
    },]
},
{
  path: '/stuexam/:semesterId/:examId/',
  props: true,
  children: [
    { 
      path: 'stupreview',
      name: 'StuPaperPreview',
      component: StuPaperPreview,
      meta: { breadcrumb: '试卷预览' } 
    },
    { 
      path: 'stusettings',
      name: 'StuExamSettings',
      component: StuExamSettings,
      meta: { breadcrumb: '规则设置' } 
    },
    { 
      path: '/stuexam/:semesterId/:examId/stuanswer-review',
      name: 'StuAnswerReview',
      component: StuAnswerReview,
      meta: { breadcrumb: '作答情况' } 
    }
    
  ]
},

{ path: '/stu-servay/:paperId', name: 'StuServayDetail', component: StuServayDetail, props: true,meta: { breadcrumb: '问卷详细' } },
  { path: '/edit-exam/:paperId', name: 'EditExamdetail', component: EditExamdetail, props: true,meta: { breadcrumb: '添加试题' } },
  { path: '/edit-survey/:paperId', name: 'EditSurveydetail', component: EditSurveydetail, props: true,meta: { breadcrumb: '添加试题' } },
  {
    path: '/new-exam/:semesterId',  // 这个路径必须和 navigateToNewExam 里的匹配
    name: 'NewExamPage',
    component: EditExamPage, // 直接加载 EditExamPage.vue
    props: true,  // 允许参数传递
    meta: { title: '创建考试' }
  },

  {
    path: '/teacher',
    component: TeacherLayout,
    meta: { breadcrumb: '教师中心' },
    children: [
      { path: 'profile', component: TeacherProfile, meta: { breadcrumb: '个人中心' } },
      { path: 'T_class', component: T_ClassPage, meta: { breadcrumb: '教学课堂' } },
      { path: 'T_qa', component: T_QA, meta: { breadcrumb: '课程管理' } },
      { path: 'TeacherSet', component: TeacherSet, meta: { breadcrumb: '个人中心' } },
      { path: 'T_images', component: T_ImagesPage, meta: { breadcrumb: '图片库' } },
      { path: 'T_word', component: T_WordPage, meta: { breadcrumb: '教学文档' } },
      { path: 'T_videos', component: T_VideosPage, meta: { breadcrumb: '教学视频' } },
      { path: 'T_other_resources', component: T_OtherResourcesPage, meta: { breadcrumb: '其他资源' } },
      { path: 'T_question_bank', component: T_QuestionBankPage, meta: { breadcrumb: '题库' } },
      { path: 'T_exam_bank', component: T_ExamBankPage, meta: { breadcrumb: '试卷库' } },
      { path: 'T_exam_bank/create-exam', component: EditExamPage, meta: { breadcrumb: '试卷库 / 创建考试' },}
]},
  {
    path: '/class-management/:id',
    component: T_ClassLayout,
    meta: { breadcrumb: '课堂管理' },
    props: (route) => ({
      classData: {
        name: '示例课程',teacherName: '张老师',classId: route.params.id,studentsCount: 30}
    }),
    children: [
      { path: '',component: T_ClassManagement,meta: { breadcrumb: '课堂管理详情' }},
      { path: 'TechNoti', component: TechNoti, meta: { breadcrumb: '通知公告' },props: true },
      { path: 'TechAssignments', component: TechAssignments, meta: { breadcrumb: '图文作业' },props: true },
      { path: 'TechExams', component: TechExams, meta: { breadcrumb: '在线考试' },props: true },
      { path: 'TechResources', component: TechResources, meta: { breadcrumb: '课件' },props: true },
      { path: 'TechVideos', component: TechVideos, meta: { breadcrumb: '教学视频' },props: true },
      { path: 'TechMaterials', component: TechMaterials, meta: { breadcrumb: '学生管理' },props: true },
      { path: 'TechOther', component: TechOther, meta: { breadcrumb: '其他资源' },props: true },
      { path: 'TechSurveys', component: TechSurveys, meta: { breadcrumb: '问卷调查' },props: true },
      { path: 'TechData', component: TechData, meta: { breadcrumb: '数据统计' },props: true },//教师
      { path: 'ResourceViewer', component: ResourceViewer, meta: { breadcrumb: '资源查看' },props: true },
    ]
  },

  { 
    path: '/student', 
    component: StudentLayout, 
    meta: { breadcrumb: '学生中心' },
    children: [
      { path: 'profile', component: StudentProfile, meta: { breadcrumb: '个人中心' } },
      { path: 'class', component: ClassPage, meta: { breadcrumb: '教学课堂' } },
      { path: 'PPT', component: PPTPage, meta: { breadcrumb: '收藏课件' } },
      { path: 'videos', component: VideosPage, meta: { breadcrumb: '收藏视频' } },
      { path: 'practice', component: ImagesPage, meta: { breadcrumb: '收藏图片' } },
      { path: 'questionbank', component: QuestionBankPage, meta: { breadcrumb: '星标题目' } },
      { path: 'word', component: WordPage, meta: { breadcrumb: '收藏文档' } },
      { path: 'studentset', component: StudentSet, meta: { breadcrumb: '个人设置' } }
    ]
  },

  {
    path: '/student-management/:id',
    component: S_ClassLayout,
    meta: { breadcrumb: '课堂管理' },
    props: (route) => ({
      classData: {
        name: '示例课程',teacherName: '张老师',classId: route.params.id,studentsCount: 30}
    }),
    children: [
      { path: '',component: T_ClassManagement,meta: { breadcrumb: '课堂管理详情' }},
      { path: 'StuNoti', component: StuNoti, meta: { breadcrumb: '通知公告' },props: true },
      { path: 'StuAssignments', component: StuAssignments, meta: { breadcrumb: '图文作业' },props: true },
      { path: 'StuExams', component: StuExams, meta: { breadcrumb: '在线考试' },props: true },
      { path: 'StuResources', component: StuResources, meta: { breadcrumb: '课件' },props: true },
      { path: 'StuVideos', component: StuVideos, meta: { breadcrumb: '教学视频' },props: true },
      { path: 'StuMaterials', component: StuMaterials, meta: { breadcrumb: '实践资料' },props: true },
      { path: 'StuOther', component: StuOther, meta: { breadcrumb: '其他资源' },props: true },
      { path: 'StuSurveys', component: StuSurveys, meta: { breadcrumb: '问卷调查' },props: true },
      { path: 'StuData', component: StuData, name: 'StuData', meta: { breadcrumb: '数据统计' },props: true },
      { path: 'StuQuestion', component: StuQuestion, meta: { breadcrumb: '互动问答' },props: true },//学生课堂
      { path: 'StuResourceViewer', component: StuResourceViewer, meta: { breadcrumb: '资源查看' },props: true },

    ]
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
